/**    
* @Title: DataCenter.java
* @Package: org.vdalf.gsgz.service
* @author vDalf 2020-09-26 10:51:30 上午10:51:30
* @Copyright © 2020 vDalf Block-Chain Foundation (In Preparation Non-Governmental Organization) All rights reserved.
*/
package org.vdalf.gsgz.service;

import java.math.BigDecimal;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;


/**    
* @Title: DataCenter.java
* @Package: org.vdalf.gsgz.service
* @Description: 
* @author vDalf 2020-09-26 10:51:30 上午10:51:30
*/
public class DataCenter implements IPriceCommander{
	
	private static final DataCenter instance = new DataCenter();

	private Set<IPriceCommander> commanders = ConcurrentHashMap.newKeySet();
	
	private DataCenter() {
		super();
	}

	public static DataCenter getInstance() {
		return instance;
	}

	public void addCommander(IPriceCommander commander) {
		commanders.add(commander);
	}
	
	public void removeCommander(IPriceCommander commander) {
		commanders.remove(commander);
	}
	
	@Override
	public void updatePrice(String market, BigDecimal price) {
		commanders.parallelStream().forEach(c->c.updatePrice(market,price));
	}

}
